﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Data;
using DataAccess;
using Utility;

namespace Web.giamthi
{
    public partial class UCSinhVien : System.Web.UI.UserControl
    {
        SinhVienControl svCtr = new SinhVienControl();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                GridView1.AllowPaging = true;
                GridView1.PageSize = 15;
                LoadSinhvien();
            }
        }

        // hiển thị danh sách sinh viên
        private void LoadSinhvien()
        {
            GridView1.DataSource = svCtr.GetListSinhvien();
            GridView1.DataBind();
        }

        // chọn 1 dòng để update
        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string masv = WebHelper.GetIdGridView(GridView1, 0 , e);
            Response.Redirect("admin.aspx?page=themsinhvien&masv="+masv+"");
        }

        // phân trang
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            WebHelper.pageIndexChanging(GridView1 , e);
            LoadSinhvien();
        }
    }
}